package cn.dapeng.designPatterns.chain.t03;

import java.util.ArrayList;
import java.util.List;

public class FilterChain implements Filter {


    List<Filter> filters = new ArrayList<>();

    public FilterChain addFilter(Filter filter) {
        filters.add(filter);
        return this;
    }


    @Override
    public boolean doFilter(Msg msg) {
        for (Filter f : filters) {
            if (!f.doFilter(msg)) return false;
        }
        return true;
    }
}
